home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / newsgroups / misc.20020314-20021006 / 000257_hairyveggie@yahoo.com_Fri Aug 2 10:11:18 EDT 2002.msg < prev    next >
Text File  |  2020-01-01  |  4KB  |  89 lines

  1. Article: 13573 of comp.protocols.kermit.misc
  2. Path: newsmaster.cc.columbia.edu!panix!bloom-beacon.mit.edu!newsfeed.stanford.edu!postnews1.google.com!not-for-mail
  3. From: hairyveggie@yahoo.com (Luke Weese)
  4. Newsgroups: comp.protocols.kermit.misc
  5. Subject: Renaming a file after receiving
  6. Date: 1 Aug 2002 16:51:48 -0700
  7. Organization: http://groups.google.com/
  8. Lines: 71
  9. Message-ID: <d49c50d5.0208011551.2aeed298@posting.google.com>
  10. NNTP-Posting-Host: 12.148.134.9
  11. Content-Type: text/plain; charset=ISO-8859-1
  12. Content-Transfer-Encoding: 8bit
  13. X-Trace: posting.google.com 1028245909 14956 127.0.0.1 (1 Aug 2002 23:51:49 GMT)
  14. X-Complaints-To: groups-abuse@google.com
  15. NNTP-Posting-Date: 1 Aug 2002 23:51:49 GMT
  16. Xref: newsmaster.cc.columbia.edu comp.protocols.kermit.misc:13573
  17.  
  18. Hi.  So we all know, I am a newbie to C-Kermit scripting.  I have
  19. written some scripts to dial in to a Wildcat BBS system, choose some
  20. menu options, and receive a file using the Zmodem protocol (they
  21. support Kermit protocol, but they highly recommend Zmodem because they
  22. obviously havent read the Performance chapter in the Kermit manual,
  23. judging by the 3.8% efficiency of the download).  All of this goes
  24. through fine, but the only problem I had is that when using Zmodem,
  25. the "as-name" argument to the receive command is apparently ignored. 
  26. I worked around this with some rather silly scripting involving
  27. redirecting an "ls" command, parsing the filename and renaming, but I
  28. was hoping someone could suggest a less clumsy way to rename the
  29. downloaded file.  Here's the excerpt of my script:
  30.  
  31. -------------START----------------
  32. mkdir tmpdir                                    ; Make "tmpdir" to
  33. store this download
  34. if fail goto mkdirfailed                        ; Bail if permissions
  35. messed up
  36. cd tmpdir                                       ; Move into "tmpdir"
  37.  
  38. set take error on                               ; Set the error
  39. detection
  40. set terminal autodownload off                   ; Turn auto download
  41. off
  42.                                                 ; Use Zmodem protocol
  43. set protocol zmodem rz {rz -a} {sz %s} {sz -a %s} rz {rz -a}
  44.  
  45. -------------DIALING, etc...------
  46.  
  47. receive hndyinvc.dat                            ; Download the file
  48. If fail goto downloadfailure                    ; Error receiving file
  49.  
  50. .\%x := \Ffiles(*)                              ; Count the files in
  51. tmpdir
  52. If = 1 \%x ls > ../dir.txt                      ; If only 1, list to
  53. parent dir
  54. else goto oldfilesoutthere                      ; More than one file,
  55. bail
  56.  
  57. cd ..                                           ; Go back to
  58. "hndmodem"
  59. open read dir.txt                               ; Open list file
  60. if fail goto nodirfile                          ; Bail if nonexistent
  61.  
  62. read \%o                                        ; Read first line,
  63. "total n"
  64. if fail goto nodirfile                          ; Bail if nonexistent
  65. read \%o                                        ; Read 2nd line with
  66. filename
  67. if fail goto nodirfile                          ; Bail if nonexistent
  68.  
  69. .\%d := \Fsubstring(\%o,57)                     ; Get filename from
  70. pos 57 on
  71. cd tmpdir                                       ; Go back to "tmpdir"
  72. If exist \%d mv \%d ../hndyinvc.dat             ; If there, move back
  73. and rename
  74. cd ..                                           ; Go back to
  75. "hndmodem"
  76.  
  77. rmdir tmpdir                                    ; Remove "tmpdir" for
  78. next time
  79. If fail echo Could not remove "tmpdir" automatically. Please remove
  80. manually.
  81. rm dir.txt                                      ; Remove "dir.txt"
  82. If fail echo Could not remove "dir.txt" automatically. Please remove
  83. manually.
  84.  
  85. ------------FINISH----------------
  86.  
  87. Please excuse any newbie mistakes in the coding, but feel free to
  88. point them out.  Thanks in advance for any help.
  89.